using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DialogGroup : MonoBehaviour
{
    public float dialogIntervalTime;

    public float dialogGroupMoveSpeed;

    public List<GameObject> dialogBoxes;
    private int currentDialogBox;
    
    public GameObject rightMaskOfNPC4;
    private void Start()
    {
        InvokeRepeating("EnableDialogBox", 0f, dialogIntervalTime);
    }

    public void EnableDialogBox()
    {
        if (currentDialogBox == dialogBoxes.Count)
        {
            CancelInvoke();
            //Destroy(gameObject);
        }
        dialogBoxes[currentDialogBox].SetActive(true);
        currentDialogBox ++;
    }

    private void Update()
    {
        Vector3 tempPos = gameObject.GetComponent<RectTransform>().position;
        tempPos.y += dialogGroupMoveSpeed * Time.deltaTime;
        gameObject.GetComponent<RectTransform>().position = tempPos;
    }

    public void DestroySelf()
    {
        Destroy(gameObject);
    }
    
    //NPC4戴口罩动画与戴口罩后规则书变化
    public void ResetSuspectWhenNPC4Leave()
    {
        //TODO: 设置Rulebook相关条目为不可置疑
        RuleBookManager.instance.clickablePartsGroupOnRuleBook[0].transform.GetChild(1).GetComponent<ClickablePart>()
            .isSuspect = false;
        RuleBookManager.instance.clickablePartsGroupOnRuleBook[0].transform.GetChild(1).GetComponent<ClickablePart>()
            .DialogGroup = null;
        rightMaskOfNPC4.GetComponent<Animator>().SetTrigger("WearMask");

    }

    //NPC specific function
    public void PutOnNPC4Mask()
    {
        NPCManager.instance.currentNPC.GetComponent<NPCController>().NPC4PutOnMask();
    }
    
    public void ActiveNPC5Arm()
    {
        NPCManager.instance.currentNPC.GetComponent<NPCController>().Arm.SetActive(true);
    }
    
    public void DeactiveNPC5Arm()
    {
        NPCManager.instance.currentNPC.GetComponent<NPCController>().Arm.SetActive(false);
    }

}


